function _key() {
    if(event.keyCode ==13)
        ask();
}

function ask(){

    //首先使用val()方法获取id为text文本框的内容
    //并赋予给value变量
    var que =window.frames['ueditor_0'].contentWindow.document.body.innerText;
    if (que=="")
    {
        alert("请输入");
        return;
    }
    var queDiv="<div ng-repeat='record in items' class='ng-scope'>\n" +
        "                                <!-- ngIf: record.role == 'talk-a' -->\n" +
        "                                <div ng-if='record.role == &apos; talk-a &apos; ' class='ng-scope'>\n" +
        "                                    <div user-record='' record='record' class=' ng-isolate-scope'>\n" +
        "                                        <div class='talk-item talk-a'>\n" +
        "                                            <div class='talk-item-container'>\n" +
        "                                                <div class='talk-item-content'>\n" +
        "                                                    <img class='head-photo'\n" +
        "                                                         ng-src='https://bos.nj.bpc.baidu.com/v1/nightingale/channelconfig/20160905/bf7cd451-3cba-4421-b0b3-b1fd6ac620cb.png'\n" +
        "                                                         src='./img/icons.png '>\n" +
        "                                                    <div class='message-text'>\n" +
        "                                                        <div msg-content='' detail='record.detail'\n" +
        "                                                             class='ng-isolate-scope'>\n" +
        "                                                            <div ng-controller='MsgCtrl' class='msg-cnt ng-scope'>"+
        que+"</div>\n" +
        "                                                        </div>\n" +
        "                                                        <div msg-feedback='' nlp-feedback='record.nlpFeedback'\n" +
        "                                                             class='ng-isolate-scope'>\n" +
        "                                                            <!-- ngIf: nlpFeedback.detail.length > 0 -->\n" +
        "                                                        </div> <!-- ngIf: record.nlpPredictList.length > 0 -->\n" +
        "                                                    </div>\n" +
        "                                                </div>\n" +
        "                                            </div>\n" +
        "                                        </div>\n" +
        "                                    </div>\n" +
        "                                </div><!-- end ngIf: record.role == 'talk-a' -->\n" +
        "                                <!-- ngIf: record.role == 'talk-notice' -->\n" +
        "                            </div><!-- end ngRepeat: record in items -->\n"
    document.getElementById("ansDiv").innerHTML+=queDiv;





    //定义ajax()
    $.ajax({

        //tyep:设置提交方式（get|post）
        type:"post",
        //url:提交到那个servlet，这里写它的路径
        url:"./dialog.do",
        //data:定义数据,以键值对的方式放在大括号里
        data:{que:que},
        //statusCode:状态码，用于定义执行时提示的状态
        statusCode:{
            404:function(){
                alert("404");
            },
            500:function(){
                alert("500");
            }
        },
        //success:当ajax完成操作并且不出现异常执行它，自定义参数massage是用于存放servlet响应的数据，Status为ajax执行的状态
        success:function(massge,Status){
            var getjson = JSON.parse(massge);
            var ans0=getjson.ans0;
            var ans1=getjson.ans1;
            var ans2=getjson.ans2;
            var ans3=getjson.ans3;
            var ans4=getjson.ans4;
            var ans5=getjson.ans5;
            document.getElementById("ans1").innerText=ans1;
            document.getElementById("ans2").innerText=ans2;
            document.getElementById("ans3").innerText=ans3;
            document.getElementById("ans4").innerText=ans4;
            document.getElementById("ans5").innerText=ans5;
            //alert(que);
            //提示状态
            //alert(Status);
            //将h1的值替换为servlet返回的值
            //$("#answers").innerHTML(massge);
            var str="<div ng-repeat='record in items' class='ng-scope'>\n" +
            "                                <!-- ngIf: record.role == 'talk-b' -->\n" +
            "                                <div ng-if='record.role == &apos; talk-b &apos; ' class='ng-scope'>\n" +
            "                                    <div user-record='' record='record' class=' ng-isolate-scope'>\n" +
            "                                        <div class='talk-item talk-b'>\n" +
            "                                            <div class='talk-item-container'>\n" +
            "                                                <div class='talk-item-content'>\n" +
            "                                                    <img class='head-photo'\n" +
            "                                                         ng-src='https://bos.nj.bpc.baidu.com/v1/nightingale/channelconfig/20160831/13701e97-9f30-4a7d-ae11-54536dd44965.png'\n" +
            "                                                         src='./img/icon_hover.png'>\n" +
            "                                                    <div class='message-text'>\n" +
            "                                                        <div msg-content='' detail='record.detail'\n" +
            "                                                             class='ng-isolate-scope'>\n" +
            "                                                            <div ng-controller='MsgCtrl' class='msg-cnt ng-scope'>\n"
            +ans0+
            "                                                            </div>\n" +
            "                                                        </div>\n" +
            "                                                        <div msg-feedback='' nlp-feedback='record.nlpFeedback'\n" +
            "                                                             class='ng-isolate-scope'>\n" +
            "                                                            <!-- ngIf: nlpFeedback.detail.length > 0 -->\n" +
            "                                                        </div> <!-- ngIf: record.nlpPredictList.length > 0 -->\n" +
            "                                                    </div>\n" +
            "                                                </div>\n" +
            "                                            </div>\n" +
            "                                        </div>\n" +
            "                                    </div>\n" +
            "                                </div><!-- end ngIf: record.role == 'talk-a' -->\n" +
            "                            </div>";
            document.getElementById("ansDiv").innerHTML+=str;
            window.frames['ueditor_0'].contentWindow.document.body.innerText="";
        }

    });
}

function sleep(delay) {
    var start = (new Date()).getTime();
    while ((new Date()).getTime() - start < delay) {
        continue;
    }
}